package com.dq.Service.Impl;

import com.dq.Mapper.ShareMapper;
import com.dq.Pojo.Sharecourse;
import com.dq.Service.ShareService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShareServiceImpl implements ShareService {
    @Autowired
    private ShareMapper shareMapper;

    @Override
    public void add(Sharecourse sharecourse) {
        shareMapper.add(sharecourse);
    }

    @Override
    public Sharecourse findById(Integer classid, Integer courseid) {
        return shareMapper.findById(classid,courseid);
    }

    @Override
    public PageInfo<Sharecourse> findAll(Integer pageNum, Integer pageSize, String courseid, String classid, String teaid) {
        PageHelper.startPage(pageNum,pageSize);
        List<Sharecourse> sharecourseList=shareMapper.findAll(courseid,classid,teaid);
        PageInfo<Sharecourse> pageInfo=new PageInfo<>(sharecourseList);
        return pageInfo;
    }

    @Override
    public void delete(Integer id) {
        shareMapper.delete(id);
    }

    @Override
    public List<Sharecourse> findBystuid(Integer id) {
        return shareMapper.findBystuid(id);
    }

    @Override
    public List<Sharecourse> findByteaid(Integer id) {
        return shareMapper.findByteaid(id);
    }
}
